#include <typeindex>
#include <iostream>
class Base{
    public:
    virtual ~Base() = default;
};

class Derived : public Base{
    public:
    // 知识回顾：
    // 虽然这里定义了子类的构造函数，但是
    // 用基类指针Base* pBase = new Derived(2);
    // 这样是不会调用子类的构造函数的
    Derived(int num){
        std::cout << "int";
    }
    Derived(double num){
        std::cout << "double";
    }
    void print(double num){
        std::cout << "double";
    }
    void print(int num){
        std::cout << "int";
    }    
};

int main()
{
    Base* base = new Derived(2);
    // base->print();
    std::type_index base_t = typeid(*base);
    std::type_index base_d = typeid(Derived);
    
    if(base_t == base_d){
        std::cout << "Same type" << std::endl;
    }else{
        std::cout << "Diff type" << std::endl;
    }

    Derived* pDerived1 = new Derived(2);
    Derived* pDerived2 = new Derived(2.0);

    return 0;
}